
head = [1,2,3,4]

var swapPairs = function(head) {
    const dummy=new ListNode(0)
    dummy.next=head
    let curr=dummy
    post=null
    while(curr.next!==null&&curr.next.next!==null)
    {
        post=curr.next
        curr.next=post.next
         post.next=post.next.next
         curr.next.next=post
         curr=post
    }
    return dummy.next
    
};
console.log(swapPairs(head));

